package logic.characters;

import logic.enemies.Enemy;
import logic.pruebas.GamePanel;
import logic.threads.ShootBullet;

public class Wario extends Player{
	private static final long serialVersionUID = -548354665973626999L;

	public Wario(int x, int y, GamePanel panel, String nomImg, int salud, int attack, int defense, int magic, int resistance, int speed, int jump, int stamina, int[] abilitiesIDs ) {
		super(x, y, panel, nomImg, salud, attack, defense, magic, resistance, speed, jump, stamina, abilitiesIDs);
		specialCost = 5;
		shootCost = 2;
		staminaRecovery = 2;
		lifeRecovery = 1;
		widthDifference = 33;
		heightDifference = 5;
		collisionWidth = 40;
		collisionHeight = altura - heightDifference;
		specialTime = 1500;
		attackTime = 700;
		shootTime = 700;
	}

	@Override
	public void shoot() {
		Runnable shootBullet = new ShootBullet(collisionX, collisionY, panelJuego, lookingRight, enemies, blocks, magic, true, this, shootTime);
		Thread fThread = new Thread(shootBullet);
		fThread.start();
		
	}

	@Override
	public void specialEffect(Enemy enemy) {
		enemy.velX = -enemy.velX * 2;
		enemy.damage((int)(attack * 1.5));
	}
	
	public void special() {
		if (stamina >= specialCost) {
		if (!attacking && !jumping && !throwing) {
			if (!special) {
				stamina -= specialCost;
			}

			if (lookingRight) {
				velX = 400;
			} else {
				velX = -400;
			}
		special = true;
		if (lookingRight) {
				updateIcon("resources" + getClass().getSimpleName() + "/SR.gif");
		} else {
				updateIcon("resources" + getClass().getSimpleName() + "/SL.gif");
		}
		lastActionTime = System.currentTimeMillis();
		dibujar();
		}
		}
	}
	
	public void endSpecial() {
		long now = System.currentTimeMillis();
		
		if ((now - lastActionTime) >= specialTime) {
			if (!jumping && !attacking && !throwing) {
				if (lookingRight) {
					updateIcon("resources" + getClass().getSimpleName() + "/IR.gif");
					dibujar();
					movementAllowed = true;
					special = false;
				} else {
					updateIcon("resources" + getClass().getSimpleName() + "/IL.gif");
					dibujar();
					movementAllowed = true;
					special = false;
				}
			}
			velX = 0;
		}
		}


}
